home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / previe_1 / previewp.h < prev    next >
C/C++ Source or Header  |  1998-10-28  |  5KB  |  161 lines

  1. // PreviewPrintDoc.h : interface of the CPreviewPrintDoc class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4.  
  5. #if !defined(AFX_PREVIEWPRINTDOC_H__D5E5B1B2_68E7_11D2_BEF9_0080C770FCBD__INCLUDED_)
  6. #define AFX_PREVIEWPRINTDOC_H__D5E5B1B2_68E7_11D2_BEF9_0080C770FCBD__INCLUDED_
  7.  
  8. #if _MSC_VER >= 1000
  9. #pragma once
  10. #endif // _MSC_VER >= 1000
  11.  
  12. class CPage : public CObject
  13. {
  14. public:
  15.     DECLARE_SERIAL(CPage)
  16.  
  17. //members
  18. public:
  19.     int         nPage;
  20.     HMETAFILE   hmf;
  21.  
  22. //methods
  23. public:
  24.     CPage() { nPage = -1; hmf = NULL; };
  25.     ~CPage() { DeleteMetaFile(hmf); };
  26.  
  27. protected:
  28.     virtual void Serialize(CArchive& ar);
  29. };
  30.  
  31. typedef CTypedPtrArray<CObArray,CPage*> CPageArray;
  32.  
  33. class CPreviewPrintDoc : public CDocument
  34. {
  35.     //TODO: remove this friend class
  36.     friend class CPreviewPrintView;
  37.  
  38. protected:
  39.     enum {
  40.         PPF_BOLD = 1,
  41.         PPF_ITALIC = 2,
  42.         PPF_UNDERLINE = 4,
  43.         PPF_STRIKEOUT = 8
  44.     };
  45.  
  46. protected: // create from serialization only
  47.     CPreviewPrintDoc();
  48.     DECLARE_DYNCREATE(CPreviewPrintDoc)
  49.  
  50. // Attributes
  51. public:
  52.     CString m_strAppTitle;
  53.  
  54. protected:
  55.     BOOL        m_bInDocument;
  56.     HDC         m_hdcPrinter;
  57.     CMetaFileDC *m_pmfCurr;
  58.     CPageArray  m_rgPage;
  59.     int         m_nCurrPage;
  60.  
  61.     short       m_nOrientation;
  62.     short       m_nPageHeight;
  63.     short       m_nPageWidth;
  64.  
  65.     LOGFONT     m_lfCurrFont;
  66.     LOGPEN      m_lpCurrPen;
  67.  
  68.     CWnd        m_wndOwner;
  69.     short       m_nState;
  70.  
  71. // Operations
  72. public:
  73.     int GetNumPages(void) { return m_rgPage.GetSize(); };
  74.     int GetFirstPage(void) { return m_nStartPage; };
  75.     int GetLastPage(void) { return (m_nStartPage + m_rgPage.GetSize() - 1); };
  76.     void PrintPage(int nPage, CDC *pDC, CPrintInfo* pInfo);
  77.     void SetPreviewPrintState(int nState) { m_nState = nState; };
  78.  
  79.     enum {
  80.         PPSTATE_IDLE = 0, 
  81.         PPSTATE_PREVIEW = 1,
  82.         PPSTATE_PRINT = 2 
  83.     };
  84.  
  85. protected:
  86.     void AddLine(const CString &strLine);
  87.     BOOL CompletePage(void);
  88.     void SetUserDocInfo(const LPDEVMODE lpdm);
  89.     void SetLogFont(LOGFONT *lplf, LPCTSTR lpszFaceName, 
  90.                     short nSize, short nOptions, short nAngle) ;
  91.     void SetLogPen(LOGPEN *lplp, UINT nStyle, int nWidth, COLORREF nColor);
  92.  
  93. // Overrides
  94.     // ClassWizard generated virtual function overrides
  95.     //{{AFX_VIRTUAL(CPreviewPrintDoc)
  96.     public:
  97.     virtual BOOL OnNewDocument();
  98.     virtual void Serialize(CArchive& ar);
  99.     //}}AFX_VIRTUAL
  100.  
  101. // Implementation
  102. public:
  103.     virtual ~CPreviewPrintDoc();
  104. #ifdef _DEBUG
  105.     virtual void AssertValid() const;
  106.     virtual void Dump(CDumpContext& dc) const;
  107. #endif
  108.  
  109. protected:
  110.  
  111. // Generated message map functions
  112. protected:
  113.     //{{AFX_MSG(CPreviewPrintDoc)
  114.         // NOTE - the ClassWizard will add and remove member functions here.
  115.         //    DO NOT EDIT what you see in these blocks of generated code !
  116.     //}}AFX_MSG
  117.     DECLARE_MESSAGE_MAP()
  118.  
  119.     // Generated OLE dispatch map functions
  120.     //{{AFX_DISPATCH(CPreviewPrintDoc)
  121.     short m_nStartPage;
  122.     afx_msg short GetOrientation();
  123.     afx_msg void SetOrientation(short nNewValue);
  124.     afx_msg short GetPageWidth();
  125.     afx_msg short GetPageHeight();
  126.     afx_msg long GetHwndOwner();
  127.     afx_msg void SetHwndOwner(long nNewValue);
  128.     afx_msg short GetPreviewPrintState();
  129.     afx_msg BOOL BeginDoc();
  130.     afx_msg BOOL EndDoc();
  131.     afx_msg BOOL GetPos(short FAR* x, short FAR* y);
  132.     afx_msg void MoveTo(short x, short y);
  133.     afx_msg BOOL LineTo(short x, short y);
  134.     afx_msg BOOL SetFont(LPCTSTR lpszFaceName, short nSize, short nOptions, short nAngle);
  135.     afx_msg BOOL TextOut(short x, short y, LPCTSTR szText);
  136.     afx_msg short SetTextAlign(short nOptions);
  137.     afx_msg short GetTextAlign();
  138.     afx_msg long SetBkColor(long crColor);
  139.     afx_msg long GetBkColor();
  140.     afx_msg long SetTextColor(long crColor);
  141.     afx_msg long GetTextColor();
  142.     afx_msg BOOL NewPage();
  143.     afx_msg void KillDoc();
  144.     afx_msg BOOL GetTextExtent(LPCTSTR lpszText, short FAR* nWidth, short FAR* nHeight);
  145.     afx_msg BOOL SetLineStyle(short nStyle, short nWidth, long crColor);
  146.     afx_msg void SetTitle(LPCTSTR lpszApp, LPCTSTR lpszDoc);
  147.     afx_msg BOOL ShowPreview();
  148.     afx_msg BOOL ShowPrintSetup();
  149.     afx_msg BOOL TextOutClip(short x, short y, LPCTSTR szText, short nClipLeft, short nClipTop, short nClipRight, short nClipBottom);
  150.     //}}AFX_DISPATCH
  151.     DECLARE_DISPATCH_MAP()
  152.     DECLARE_INTERFACE_MAP()
  153. };
  154.  
  155. /////////////////////////////////////////////////////////////////////////////
  156.  
  157. //{{AFX_INSERT_LOCATION}}
  158. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  159.  
  160. #endif // !defined(AFX_PREVIEWPRINTDOC_H__D5E5B1B2_68E7_11D2_BEF9_0080C770FCBD__INCLUDED_)
  161.